import { CheckCircleOutlined, CloseCircleOutlined } from '#/utils/antdIcons.js';
import { Tooltip } from 'antd';
import styles from './index.less';
// 基础表格样式
export const baseTableStyle = {
  // '--header-bgcolor': '#434749',
  '--header-color': 'white',
  '--border-color': 'rgba(255, 255, 255, 0.1)',
  '--header-row-height': '36px',
  '--font-size': '12px',
  '--cell-border-vertical': '1px solid rgba(255, 255, 255, 0.1)',
  '--header-cell-border-vertical': '1px solid rgba(255, 255, 255, 0.1)',
  '--bgcolor': '#222629',
  '--color': 'white',
  '--hover-bgcolor': '#222629',
  '--cell-padding': '4px 5px',
  border: '1px solid #444',
  borderRadius: '5px',
};
const getIcon = (v) => {
  return v ? (
    <CheckCircleOutlined style={{ color: '#30D485', fontSize: 14 }} />
  ) : (
    <CloseCircleOutlined style={{ color: '#FD4F43', fontSize: 14 }} />
  );
};
export const columns = [
  {
    code: 'stationName',
    title: '场站名称',
    align: 'left',
    width: 120,
    render(text) {
      return !!text ? text : <span style={{ color: 'var(--font-a40)' }}>/</span>;
    },
  },
  {
    code: 'projectCompanyName',
    title: '项目公司',
    align: 'left',
    width: 120,
    // render(text) {
    //   return !!text ? text : <span style={{ color: "rgba(255, 255, 255, 0.4)" }}>/</span>
    // }.
  },
  {
    code: 'projectType',
    title: '类型',
    align: 'center',
    render(text) {
      return !!text ? text : <span style={{ color: 'var(--font-a40)' }}>/</span>;
    },
  },
  {
    code: 'regionalManager',
    title: '区域经理',
    align: 'center',
    render(text, row) {
      if (!!text) {
        return (
          <Tooltip
            placement="bottomLeft"
            title={() => (
              <div className={styles.tooltip_box}>
                <div>
                  姓名<span>{row.regionalManager}</span>
                </div>
                <div>
                  电话<span>{row.regionalManagerEmail}</span>
                </div>
                <div>
                  邮箱<span>{row.regionalManagerPhone}</span>
                </div>
              </div>
            )}
          >
            {text}
          </Tooltip>
        );
      } else {
        return <span style={{ color: 'var(--font-a40)' }}>/</span>;
      }
    },
  },
  {
    code: 'personInCharge',
    title: '负责人',
    align: 'center',
    render(text, row) {
      if (!!text) {
        return (
          <Tooltip
            placement="bottomLeft"
            title={() => (
              <div className={styles.tooltip_box}>
                <div>
                  姓名<span>{row.personInCharge}</span>
                </div>
                <div>
                  电话<span>{row.personInChargeEmail}</span>
                </div>
                <div>
                  邮箱<span>{row.personInChargePhone}</span>
                </div>
              </div>
            )}
          >
            {text}
          </Tooltip>
        );
      } else {
        return <span style={{ color: 'var(--font-a40)' }}>/</span>;
      }
    },
  },
  {
    code: 'businessFinance',
    title: '业务财务',
    align: 'center',
    render(text, row) {
      if (!!text) {
        return (
          <Tooltip
            placement="bottomLeft"
            title={() => (
              <div className={styles.tooltip_box}>
                <div>
                  姓名<span>{row.businessFinance}</span>
                </div>
                <div>
                  电话<span>{row.businessFinanceEmail}</span>
                </div>
                <div>
                  邮箱<span>{row.businessFinancePhone}</span>
                </div>
              </div>
            )}
          >
            {text}
          </Tooltip>
        );
      } else {
        return <span style={{ color: 'var(--font-a40)' }}>/</span>;
      }
    },
  },
  {
    code: 'whiteList',
    title: '白名单',
    align: 'center',
    render(bool) {
      return getIcon(bool);
    },
  },
  {
    code: 'renewable',
    title: '可再生',
    align: 'center',
    render(bool) {
      return getIcon(bool);
    },
  },
  {
    code: 'chinaGreenCertificate',
    title: '中国绿证',
    align: 'center',
    render(bool) {
      return getIcon(bool);
    },
  },
  {
    code: 'beiJiaoSuo',
    title: '北交所',
    align: 'center',
    render(bool) {
      return getIcon(bool);
    },
  },
  {
    code: 'guangJiaoSuo',
    title: '广交所',
    align: 'center',
    render(bool) {
      return getIcon(bool);
    },
  },
  {
    code: 'actlInvGreenCertificate',
    title: '实际库存绿证(个)',
    align: 'right',
    width: 80,
    render(text) {
      return text != '' && text != null ? (
        text
      ) : (
        <span style={{ color: 'var(--font-a40)' }}>0</span>
      );
    },
  },
];
export const done_config = [
  { label: '已办完', value: 1 },
  { label: '未办完', value: 0 },
];
export const configArr = (type) => {
  const dataType = type ? 'select' : 'label';
  const done_select = dataType == 'select' ? 'done_select' : 'label';
  let infos = [
    {
      title: '基本信息',
      columns: [
        {
          dataType: 'label',
          title: '项目名称(核准、审批或备案)',
          code: 'stationName',
          value: '',
          span: 8,
        },
        {
          dataType: 'label',
          title: '项目公司名称',
          code: 'projectCompanyName',
          value: '',
          span: 8,
        },
        // {
        //   dataType: 'label',
        //   title: 'sap名称',
        //   code: 'sap名称',
        //   span: 8,
        // },
        // {
        //   dataType: 'label',
        //   title: 'EAM名称',
        //   code: 'EAM名称',
        //   span: 8,
        // },
        {
          dataType: 'label',
          title: '大区',
          code: 'region',
          value: '',
          span: 8,
        },
        {
          dataType: 'label',
          title: '省份',
          code: 'provinceCode',
          value: '',
          span: 8,
        },
        {
          dataType: 'label',
          title: '核准容量(MW)',
          code: 'buildApprovedCapacity',
          value: '',
          span: 8,
        },
        {
          dataType: 'label',
          title: '装机容量(MW)',
          code: 'contractCapacity',
          value: '',
          span: 8,
        },
        {
          dataType: 'label',
          title: '项目类型',
          code: 'projectType',
          value: '',
          span: 8,
        },
        // {
        //   dataType: 'label',
        //   title: '状态',
        //   code: '正常',
        //   span: 8,
        // },
        {
          dataType: 'label',
          title: '并网时间(MW)',
          code: 'allOnGridTime',
          value: '',
          span: 8,
        },
      ],
    },
  ];
  let obj = {
    title: '绿证信息',
    columns: [
      {
        dataType: 'label',
        title: '补贴信息',
        code: 'subsidizeType', //替换为表单字段
        value: '',
        span: 8,
      },
      {
        dataType,
        title: '负责人',
        code: 'personInCharge',
        value: '',
        span: 8,
      },
      {
        dataType,
        title: '业务财务',
        code: 'businessFinance',
        value: '',
        span: 8,
      },
      {
        dataType: 'label',
        title: '区域经理',
        code: 'regionalManager',
        value: '',
        span: 8,
      },
      {
        dataType: done_select,
        title: '白名单',
        code: 'whiteList',
        value: '',
        span: 8,
      },
      {
        dataType: done_select,
        title: '可再生',
        code: 'renewable',
        value: '',
        span: 8,
      },
      {
        dataType: done_select,
        title: '中国绿证',
        code: 'chinaGreenCertificate',
        value: '',
        span: 8,
      },
      {
        dataType: done_select,
        title: '北交所',
        code: 'beiJiaoSuo',
        value: '',
        span: 8,
      },
      {
        dataType: done_select,
        title: '广交所',
        code: 'guangJiaoSuo',
        value: '',
        span: 8,
      },
    ],
  };
  // 编辑时逻辑更改
  if (type) {
    let editColumns = [];
    let advance_index = 0; // 上一个提前元素的标记
    for (var i = 0; i < obj.columns.length; i++) {
      if (obj.columns[i].dataType == 'label') {
        editColumns.splice(advance_index, 0, obj.columns[i]);
        advance_index++;
      } else {
        editColumns.push(obj.columns[i]);
      }
    }
    obj.columns = editColumns;
  }
  infos.push(obj);
  return infos;
};

// 概览表格表头
export const overviewColumns = [
  {
    code: '_title',
    title: '聚合维度',
    align: 'center',
  },
  {
    code: '结算单电量(MWh)',
    title: '结算单电量(MWh)',
    align: 'center',
    width: 120,
  },
  {
    code: '绿证交易绿证数(个)',
    title: '绿证交易绿证数(个)',
    align: 'center',
    width: 120,
  },
  {
    code: '理论生产总量(个)',
    title: '理论生产总量(个)',
    align: 'center',
    width: 120,
  },
  {
    code: '核发绿证(个)',
    title: '核发绿证(个)',
    align: 'center',
    width: 120,
  },
  {
    code: '已售绿证(个)',
    title: '已售绿证(个)',
    align: 'center',
    width: 120,
  },
  {
    code: '实际库存绿证(个)',
    title: '实际库存绿证(个)',
    align: 'center',
    width: 120,
  },
];
